<?php

use yii\helpers\Url;
use backend\widgets\GridView;
use yii\widgets\LinkPager;
$this->title = '游客列表';
?>

<div class="RightCenter clear">
    <div class="RightTime">
        <div class="Time">
            <h3>游客列表</h3>

            <div class="input-prepend input-group right_Time">
                <span class="add-on input-group-addon Read_IN"></span>
                <input type="text" readonly  name="birthday" id="reservation" class="form-control form-controlCLOC"/>
                <b class="caret"></b>
            </div>

        </div>
    </div>
     <div class="Read_date" style="margin-top:0px;margin-bottom: 5px;height:20px;">
    </div>
    <?php
    echo GridView::widget([
        'layout' => "{items}",
        'dataProvider' => $dataProvider,
        'tableOptions' => ['class' => 'Atable my_ta_ble clace_Top'],
        'columns' => [
            [
                'label' => '游客ID',
                'attribute' => 'id',
            ],
            [
                'label' => '游客来源',
                'format'=>'raw',
                'contentOptions' => ['class'=>'TR_Tows'],
                'value' => function($data) 
                {
                    return '<a href="JavaScript:;" class="One">'.$data['channel'].'</a></br><a href="JavaScript:;" class="Tow">'.$data['partner'].'</a>';
                }
            ],
            [
                'label' => '详细来源',
                'format'=>'raw',
                'contentOptions' => ['class'=>'TR_Tows'],
                'value' => function($data) 
                {
                    return '<a href="JavaScript:;" class="One">'.$data['novel'].'</a></br><a href="JavaScript:;" class="Tow">'.$data['recommend_sn'].'</a>';
                }
            ],
            [
                'label' => '访问时间',
                'attribute' => 'last_login_time',
            ],
        ],
    ]);
            ?>
    <div style="float: right;margin-right: 1.7%;">
        <?php echo LinkPager::widget(['pagination' => $pagination]) ?>
    </div>
</div>
<script>

    var myDate = new Date(); //获取今天日期
    var myYear = myDate.getFullYear() //获取年份
    myDate.setDate(myDate.getDate() - 7);
    var dateArray = [];
    var dateTemp;
    var flag = 1;
    for (var i = 0; i < 7; i++) {
        dateTemp = (myDate.getMonth() + 1) + "-" + myDate.getDate();
        dateArray.push(dateTemp);
        myDate.setDate(myDate.getDate() + flag);
    }
    var Start = myYear + "-" + dateArray[6]
    var S = "<?php echo $select['start'] ? date('Y-m-d',strtotime($select['start'])) : '';?>";
    var E = "<?php echo $select['end'] ? date('Y-m-d',strtotime($select['end'])) : '';?>";
    if(S == ''){
        $("#reservation").val(Start + " " + "-" + " " + Start)
    }else{
        $("#reservation").val(S + " " + "-" + " " + E)
    }
    $('#reservation').daterangepicker(null, function (start, end, label) {
        var s = moment(start).format("YYYY-MM-DD HH:mm:ss");
        var e = moment(end).format("YYYY-MM-DD HH:mm:ss");
        $("#reservation").val(S + " " + "-" + " " + E)
        location.href="/user/visitor?start="+s+"&end="+e;
    });
    
</script>